package cn.wolfcode.tieba.redis.util;

import cn.wolfcode.tieba.util.Consts;
import lombok.Getter;
import lombok.Setter;

/**
 * @author 王金龙
 * @date 2021/1/12 18:40
 */
@Getter
public enum RedisKeys {
    /**
     * 用户注册验证码
     */
    USER_VERIFY_CODE("user_verify_code", (long) (Consts.VERIFY_CODE_VAI_TIME * 60)),
    /**
     * 攻略点赞
     */
    STRATEGY_THUMB("strategy_thumb",-1L),
    /**
     * 用户登录令牌
     */
    USER_LOGIN_TOKEN("user_login_token", (long) (Consts.USER_INFO_TOKEN_VAI_TIME * 60)),

    /**
     * 用户攻略收藏
     */
    USER_STRATEGY_FAVOR("user_strategy_favor",-1L),

    /**
     * 攻略统计值对象
     */
    STRATEGY_STATIS_VO("strategy_statis_vo",-1L);

    @Setter
    private String prefix;
    @Setter
    private Long time;

    RedisKeys(String prefix, Long time) {
        this.prefix = prefix;
        this.time = time;
    }

    public static String join(RedisKeys keys, String... values) {
        StringBuilder stringBuilder = new StringBuilder(80);
        stringBuilder.append(keys);
        for (String value : values) {
            stringBuilder.append(":").append(value);
        }
        return stringBuilder.toString();
    }

}
